package ui.administrator;

import java.awt.EventQueue;

import javax.swing.JInternalFrame;
import java.awt.Color;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JLabel;

import model.Sponsor;

import controller.AdministratorController;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Set;

public class VizualizareSponsori extends JPanel {
	private JTable table;
	private JTextField textField;
	private AdministratorController adminController;
	private DefaultTableModel tsponsori;



	public AdministratorController getAdminController() {
		return adminController;
	}
	public void setAdminController(AdministratorController adminController) {
		this.adminController = adminController;
	}
	/**
	 * Create the frame.
	 */
	public VizualizareSponsori() {
		
		setBorder(null);
		setBackground(new Color(240, 255, 255));
		setBounds(100, 100, 923, 515);
		setLayout(null);
		
		JScrollPane scrollPane = new JScrollPane();
		scrollPane.setBounds(57, 30, 760, 258);
		add(scrollPane);
		
		table = new JTable();
		table.setFont(new Font("Arial", Font.PLAIN, 14));
		table.setModel(new DefaultTableModel(
			new Object[][] {
			},
			new String[] {
				"ID","Nume", "Suma", "Adresa", "Telefon","CNP"
			}
		) {
			Class[] columnTypes = new Class[] {
				String.class, String.class, String.class, String.class, String.class
			};
			public Class getColumnClass(int columnIndex) {
				return columnTypes[columnIndex];
			}
		});
		scrollPane.setViewportView(table);
		tsponsori= (DefaultTableModel) table.getModel();
		
		JButton btnNewButton = new JButton("Sterge Sponsor");
		btnNewButton.setFont(new Font("Arial", Font.PLAIN, 14));
		btnNewButton.setBounds(673, 338, 144, 23);
		add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("Editeaza");
		btnNewButton_1.setFont(new Font("Arial", Font.PLAIN, 14));
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
			}
		});
		btnNewButton_1.setBounds(529, 338, 124, 23);
		add(btnNewButton_1);
		
		JButton btnCautaAsistent = new JButton("Cauta Sponsor");
		btnCautaAsistent.setFont(new Font("Arial", Font.PLAIN, 14));
		btnCautaAsistent.setBounds(358, 338, 137, 23);
		add(btnCautaAsistent);
		
		textField = new JTextField();
		textField.setBounds(100, 339, 210, 20);
		add(textField);
		textField.setColumns(10);
		
		JLabel lblCnp = new JLabel("Nume:");
		lblCnp.setFont(new Font("Arial", Font.BOLD, 14));
		lblCnp.setBounds(44, 341, 46, 14);
		add(lblCnp);

	}
	public void getSponsori(){
		tsponsori.getDataVector().removeAllElements();
		Set<Sponsor> sponsori=adminController.getSponsori();
		for (Sponsor s : sponsori) {
			tsponsori.addRow(new Object[]{s.getSponsorId(),s.getNume(),s.getSuma(),s.getAdresa(),s.getTelefon(),s.getCnp()});
		}
	}
}
